package com.lxb.myforum.pojo

import java.util.Date

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.Lob
import javax.persistence.ManyToOne
import javax.persistence.Table
import javax.persistence.Temporal
import javax.persistence.TemporalType

/**
 * 文章评论
 *
 * @author lxb
 */
@Entity
@Table(name = "t_comment")
data class Comment(

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        var id: Long? = null,

        @Lob
        @Column(name = "content", columnDefinition = "TEXT")
        var content: String? = null,

        @Temporal(TemporalType.TIMESTAMP)
        @Column(name = "create_time")
        var createTime: Date? = null,

        @Temporal(TemporalType.TIMESTAMP)
        @Column(name = "update_time")
        var updateTime: Date? = null,

        @ManyToOne(targetEntity = Article::class)
        @JoinColumn(name = "article_id", referencedColumnName = "id", nullable = false)
        var article: Article? = null,

        @ManyToOne(targetEntity = User::class)
        @JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false)
        var user: User? = null
)
